// ==UserScript==
// @name           RemovableButton.uc.js
// @namespace   runningcheese@qq.com
// @description    新建一个可移动的功能按钮
// @author          runningcheese
// @version         0.0.2
// @license          MIT License
// @compatibility  Firefox 29+
// @charset         UTF-8
// @reviewURL     http://www.runningcheese.com/firefox-v8
// ==/UserScript==





//------------护眼模式-----------
(function () {
	CustomizableUI.createWidget({
		id : "EyesCare",
		label : "护眼模式",
		tooltiptext : "降低网页亮度",
		onClick : function (event) {
			switch (event.button) {
			case 0:
				// 左键：降低网页亮度
  (function(){
        var id = [12]
        var service = Components.classes["@userstyles.org/style;1"].getService(Components.interfaces.stylishStyle)
        for (var i=0; i < id.length; i++){
            var style = service.find(id[i], service.REGISTER_STYLE_ON_CHANGE);
            style.enabled = !style.enabled;
            style.save();
        }
    })();
				break;
			case 1:
				break;
			case 2:
				break;
			}
		}
	});

	var cssStr = '@-moz-document url("chrome://browser/content/browser.xul"){'
		 + '#EyesCare[cui-areatype="toolbar"] .toolbarbutton-icon {'
		 + 'list-style-image:url()'
		 + '}}'
     + '#EyesCare[cui-areatype="menu-panel"] .toolbarbutton-icon, toolbarpaletteitem[place="palette"]> #EyesCare .toolbarbutton-icon {'
		 + 'list-style-image:url()'
		 + '}}';
	var sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
	var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
	sss.loadAndRegisterSheet(ios.newURI("data:text/css;base64," + btoa(cssStr), null, null), sss.USER_SHEET);
})();


//------------护眼模式-----------
(function () {
	CustomizableUI.createWidget({
		id : "NightMode",
		label : "黑夜模式",
		tooltiptext : "启用黑夜模式",
		onClick : function (event) {
			switch (event.button) {
			case 0:
  (function(){
        var id = [13]
        var service = Components.classes["@userstyles.org/style;1"].getService(Components.interfaces.stylishStyle)
        for (var i=0; i < id.length; i++){
            var style = service.find(id[i], service.REGISTER_STYLE_ON_CHANGE);
            style.enabled = !style.enabled;
            style.save();
        }
    })();
				break;
			case 1:
				break;
			case 2:
				break;
			}
		}
	});

	var cssStr = '@-moz-document url("chrome://browser/content/browser.xul"){'
		 + '#NightMode[cui-areatype="toolbar"] .toolbarbutton-icon {'
		 + 'list-style-image:url()'
		 + '}}'
     + '#NightMode[cui-areatype="menu-panel"] .toolbarbutton-icon, toolbarpaletteitem[place="palette"]> #NightMode .toolbarbutton-icon {'
		 + 'list-style-image:url()'
		 + '}}';
	var sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
	var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
	sss.loadAndRegisterSheet(ios.newURI("data:text/css;base64," + btoa(cssStr), null, null), sss.USER_SHEET);
})();



//------------小窗模式-----------
(function () {
	CustomizableUI.createWidget({
		id : "MiniWindowMode",
		label : "小窗模式",
		tooltiptext : "启用小窗模式",
		onClick : function (event) {
			switch (event.button) {
			case 0:
  (function(){
       {window.open(decodeURIComponent(gBrowser.currentURI.spec), "_blank","resizable,scrollbars,status,title").resizeTo(430, 670); }
    })();
				break;
			case 1:
				break;
			case 2:
				break;
			}
		}
	});

	var cssStr = '@-moz-document url("chrome://browser/content/browser.xul"){'
		 + '#MiniWindowMode[cui-areatype="toolbar"] .toolbarbutton-icon {'
		 + 'list-style-image:url()'
		 + '}}'
     + '#MiniWindowMode[cui-areatype="menu-panel"] .toolbarbutton-icon, toolbarpaletteitem[place="palette"]> #MiniWindowMode.toolbarbutton-icon {'
		 + 'list-style-image:url()'
		 + '}}';
	var sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
	var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
	sss.loadAndRegisterSheet(ios.newURI("data:text/css;base64," + btoa(cssStr), null, null), sss.USER_SHEET);
})();



